package org.rjb.dao;

import java.util.Date;
import java.util.List;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.shop.technicalservice.dao.deliver.DeliverDao;
import com.shop.technicalservice.dao.order.IndentDao;
import com.shop.technicalservice.dao.order.OrderDetailDao;
import com.shop.technicalservice.model.deliver.Deliver;
import com.shop.technicalservice.model.order.Indent;
import com.shop.technicalservice.model.order.OrderDetail;

public class OrderDetailDaoDAOTest extends TestCase {
	private OrderDetailDao rd;
	private IndentDao id;
	private DeliverDao dd;
	public void setUp(){
		System.out.println("Begin Test");
		ApplicationContext ac=new ClassPathXmlApplicationContext(new String [] {"context/spring-db.xml","context/spring-dao.xml"});
		rd=(OrderDetailDao)ac.getBean("orderDetailDao");
		
		id = (IndentDao)ac.getBean("indentDao");
		dd = (DeliverDao)ac.getBean("deliverDao");
	}
	public void tearDown(){
		System.out.println("End Test");
	}
	public void testSave() throws Exception{
		OrderDetail r=new OrderDetail();
		r.setNum(1);
		Indent i = new Indent();
		List<Deliver> d=dd.findAll();
		
		 i.setDeliver(d.get(0));
		 i.setAddress("sss");
		 i.setConsignee("saai");
		 i.setPhone("02088105372");
		 i.setPostalCode("200120");
		 i.setReateTime(new Date(System.currentTimeMillis()));
		 i.setStatus(1);
		 i.setUserName("张赛");
		r.setCreateTime(new Date(System.currentTimeMillis()));
		id.save(i);
		r.setIndent(i);
		
		OrderDetail rs=rd.save(r);
		Assert.assertTrue(rs.getSequenceId()>0);
	}
	public void testDelete(){
		
	}
	public void testFindAll(){
		
	}
	public void testMerge(){
		
	}
}
